<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CheckStock extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('check_stock', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '盘点单表']);
        $table->addColumn('company_id', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '公司ID', 'signed' => false])
            ->addColumn('company_warehouse_id', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '仓库ID', 'signed' => false])
            ->addColumn('dealer_id', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '经销商ID', 'signed' => false])
            ->addColumn('create_user_id', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '创建人ID', 'signed' => false])
            ->addColumn('check_user_id', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '盘点人ID', 'signed' => false])
            ->addColumn('check_type', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '盘点类型，1=全盘,2=品类盘', 'signed' => false])
            ->addColumn('check_status', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '盘点状态，1=待盘点，2=已盘点，3已取消', 'signed' => false])
            ->addColumn('dealer_cate_id', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '分类ID', 'signed' => false])
            ->addColumn('check_time', 'integer', ['limit' => 10, 'default' => null, 'comment' => '盘点时间'])
            ->addColumn('remark', 'string', ['limit' => 255, 'default' => '', 'comment' => '备注', 'collation' => 'utf8mb4_general_ci'])
            ->addColumn('create_time', 'integer', ['limit' => 10, 'default' => null, 'comment' => '创建时间'])
            ->addColumn('update_time', 'integer', ['limit' => 10, 'default' => null, 'comment' => '更新时间'])
            ->addColumn('delete_time', 'integer', ['limit' => 10, 'default' => null, 'comment' => '删除时间'])
            ->create();
    }
}
